package it.trekker.tests.online;

import it.trekker.dao.Excursion;
import it.trekker.dao.ExcursionCoordinate;
import org.junit.Assert;
import org.junit.Test;

public class GPSCoordinateDAOTest extends TestCommons{
	
	
	@Test
	public void insertGPSCoordinateTest() {
		Excursion excursion = insertAnExcursion("ProvaCoordinate");
		ExcursionCoordinate coord = insertACoordinate(excursion, 55.2239, 10.7505);
		
		Assert.assertTrue(coord.getId() > 0);
		
		ExcursionCoordinate retrieved = excursionCoordinateDAO.findCoordinateById(coord.getId());
		Assert.assertNotNull(retrieved);
		
	}
	
	@Test
	public void removeGPSCoordinateTest() {
		Excursion excursion = insertAnExcursion("ProvaCoordinate2");
		ExcursionCoordinate coord = insertACoordinate(excursion, 55.2239, 10.7505);
		
		Assert.assertTrue(coord.getId() > 0);
		
		ExcursionCoordinate retrieved = excursionCoordinateDAO.findCoordinateById(coord.getId());
		Assert.assertNotNull(retrieved);
		
		excursionCoordinateDAO.remove(coord.getId());
		
		retrieved = excursionCoordinateDAO.findCoordinateById(coord.getId());
		Assert.assertNull(retrieved);
	}
	
}
